#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Agresso.Interface.Layer.Domain;
using Agresso.Interface.Layer.Service;
using System.Collections;
using System.IO;
using System.Configuration;

#endregion

namespace Agresso.Interface.Layer.Web
{
    public partial class UserControlHeader : UserControl
    {
        User m_current_user;
        MainForm m_mainForm;

        public UserControlHeader(string name, User currentUser, MainForm mainForm, string treenodeName )
        {
            InitializeComponent();
            m_current_user = currentUser;
            m_mainForm = mainForm;
            label4.Text = name;
            TreeNode treenodesoftmar = findInTreeNode(treenodeName, mainForm.GetMainMenuTreeView().Nodes); //mainForm.GetMainMenuTreeView().Nodes[treenodeName];
            //if (treenodesoftmar == null)
            //{
             
            //}
            foreach (TreeNode p in treenodesoftmar.Nodes)
            {
                if (p.Visible)
                {
                    ListViewItem item = listViewAlert.Items.Add(p.Text);
                    item.Tag = p;
                }
            }
        }

        private TreeNode findInTreeNode(string treenodeName, TreeNodeCollection n)
        {
            TreeNode result = null;
            result = n[treenodeName];
            if (result == null)
            {
                foreach (TreeNode p in n)
                {
                    result =findInTreeNode(treenodeName, p.Nodes);
                    if (result != null) break;
                }
            }
            return result;
        }

        private void listViewAlert_DoubleClick(object sender, EventArgs e)
        {
            if (listViewAlert.SelectedItem == null) return;
            TreeNode p = (TreeNode)listViewAlert.SelectedItem.Tag;
            p.TreeView.SelectedNode = p;
        }

    }
}